package com.totem.base.exception;

import com.totem.base.constants.ErrorCode;
import lombok.Getter;
import org.springframework.core.NestedRuntimeException;

@Getter
public class BaseException extends NestedRuntimeException {
    private static final long serialVersionUID = 3655050728585279326L;

    private int code = ErrorCode.ERROR.getCode();

    private String traceMessage;

    public BaseException(String msg) {
        super(msg);
    }

    public BaseException(int code, String msg) {
        super(msg);
        this.code = code;
    }

    public BaseException(int code, String msg, Throwable cause) {
        super(msg, cause);
        this.code = code;
    }

    public BaseException(ErrorCode errorCode) {
        this(errorCode.getCode(), errorCode.getMessage());
    }

    public BaseException(ErrorCode errorCode, Throwable cause) {
        this(errorCode.getCode(), errorCode.getMessage(), cause);
    }

    public BaseException(ErrorCode errorCode, String traceMessage) {
        this(errorCode.getCode(), errorCode.getMessage());
        this.traceMessage = traceMessage;
    }
}
